<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div v-cloak>
        <el-button size="small" type="primary" icon="el-icon-upload2" @click="show = true" :disabled="import_disable" >{{ btnText }}
        </el-button>
        <el-dialog v-loading="loading" element-loading-text="正在导入数据..." :title="btnText" width="800px" :visible.sync="show" :close-on-click-modal="false" :destroy-on-close="true"
            :close-on-press-escape="false">
            <ExcelUploader :api="api" :data="data" :tpl="tpl" :importType="importType" @success="uploadSuccess" @loadChange="loadChange"
            ></ExcelUploader>
        </el-dialog>
    </div>
</template>

<script>
import ExcelUploader from './ExcelUploader.vue';
import { getLicenseValueByKey } from '@/api/licenseinfo'
export default {
    data() {
        return {
            show: false,
            loading: false,
            import_disable: false,
        };
    },
    props: {
        btnText: { type: String, default: "导入数据" },
        importType: { type: String, default: "一房一价" },
        api: { type: String, default: "/api/v1/uploaders" },
        data: { type: Object, default:  () => ({}) },
        tpl: { type: String, default: "" },
    },

    components: { ExcelUploader },

    mounted: function () {
        // this.loadImportStatus()
    },

    computed: {

    },

    methods: {
        uploadSuccess(){
            this.show = false;
            this.$emit("success", null);
        },
        loadChange(e){
            this.loading = e;
        },
        // loadImportStatus(){
        //     getLicenseValueByKey('BATCH_IMPORT').then((resp)=>{
        //         if(resp.code!=0){
        //             return
        //         }
        //         if(resp.data == 'yes'){
        //             this.import_disable = false
        //         }
        //     })
        // }
    },
};
</script>

<style scoped></style>
